5
תגובות

plz help me

פתח משתמש_174194 ,
$root__movies = array(
    '1994' => array(
      'january' => array(
        'golden gate',
        'inside the goldmine',
        /* more movies titles ... */
      ),
      'february' => array(
        'naked',
        'my father the hero',
        /* more movies titles ... */
      ),
      'march' => array(
        'angie',
        'greedy',
        /* more movies titles ... */
      ),
      /* more months ... */
    ),
    '1995' => array(
      /* movies from 95' ... */
    ),
    /* more years & months & movies titles... */
  );


/*
user type year and/or month and/or movie titles
if user go to http://myDoman.ltd/movies/ my site print the "years" as links.
if user go to http://myDoman.ltd/movies/1994/ my site print the "months" as links.
if user go to http://myDoman.ltd/movies/1994/January/ my site print the "movies titles" as links.
if user go to http://myDoman.ltd/movies/1994/January/Golden Gate/ my site print the "movies title" with sum info.
if user go to http://myDoman.ltd/movies/1994/January/this movie not exitst/
or http://myDoman.ltd/movies/1994/this month not exitst/
or http://myDoman.ltd/movies/this years not exitst/
or http://myDoman.ltd/this array not exitst/
my site print the "404 error".

now i want to instead of using arrays i want database (mysql).
with array i do this (my site source code):

*/
$requestedString = isset($_SERVER['REDIRECT_URL']{0}) ? strtolower(trim($_SERVER['REDIRECT_URL'], '/')) : '';
 
  if(empty($requestedString)){
    echo '<a href="movies/">movies</a><br>';
  }else{
    $requestedArray = explode('/', $requestedString);
    foreach($requestedArray as $value){
      if(!isset($eval{0})) $eval = '$root__' . addslashes($value);
      else $eval .= "['". addslashes($value) ."']";
    }
   
    echo '<p><a href="../">back</a></p>';
    if(eval("return isset({$eval});")){
      $thisPage = eval("return {$eval};");
      if(is_array($thisPage)){
        echo as_links($thisPage);
      }else{
        echo "<h1>" . end($requestedArray) . "</h1>";
      }
    }else{
      echo "<h1>404</h1>";
    }
  }
 
  function as_links($array){
    $return = null;
    foreach($array as $key => $value){
      if(is_string($value)){
        $return .= "<a href=\"{$value}/\">{$value}</a><br>";
      }else{
        $return .= "<a href=\"{$key}/\">{$key}</a><br>";
      }
    }
    return $return;
  }


/* .htaccess file:
..codes..
RewriteRule . index.php [L,NC,QSA]
..more codes..
*/

5 תשובות

avatar ענה cthulhu ב 24 לאפריל 2012 #

eval = evil
קוד נוראי.
אנגלית נוראית.

avatar ענה משתמש_174194 ב 25 לאפריל 2012 #

My Hebrew is not very good..

i want to instead of using arrays use database, can you help me?

avatar ענה משתמש_174194 ב 28 לאפריל 2012 #

help?

avatar ענה cthulhu ב 28 לאפריל 2012 #

If your Hebrew isn't very good, then why are you asking such a questions here?
Don't you know about Stackoverflow?

avatar ענה משתמש_173497 ב 29 לאפריל 2012 #

Ok, ty.